// Copyright (c) 2006  John Abbott
// This file is part of the CoCoALib suite of examples.
// You are free to use any part of this example in your own programs.

#include "CoCoA/library.H"
using namespace CoCoA;
using namespace std;

//----------------------------------------------------------------------
const string ShortDescription =
  "This is a template file for example programs.  \n"
  "The program itself does nothing whatsoever.    \n";

const string LongDescription =
  "Make a copy of this file (called \"foo.C\", say) and put your code \n"
  "inside the procedure \"program\".                                  \n"
  "To compile your file in the examples directory just do this:       \n"
  "  make foo                                                         \n";
//----------------------------------------------------------------------

void program()
{
  GlobalManager CoCoAFoundations;
  // Put your code here.
  //ring Z=RingZ();
  //ZZ z(Z);
  //z=2;
  
  //ZZ z = power(10,20) + 1;
  //ZZ z=power(z,32)+15; //STRANGE!!! it pass compilation
  ZZ z=power(2,4)+1;
  //ZZ z=power(2,32)+15;
  ring Q=NewZmod(z);
  RingElem zp(Q);
	zp-=10;
  //QuotientRing Q=NewZmod(Z, power(z,32)+15);
  GlobalOutput() << IsField(Q) << "\t"<< zp <<"\t"<< power(zp,32)-1  << "\t" << -power(zp,32) <<"\t" << power(10,32) << endl;
  //for (int i=0; i<=32; i++)
	//	GlobalOutput() <<  i<< "\t" <<power(zp,i) << endl;// ^ is not power computation in C/C++

	//SparsePolyRing P=NewPolyRing(Q,symbols("x","y","z"));
	//SparsePolyRing P=NewPolyRing(Q,symbols("x","y","z"));
	SparsePolyRing P=NewPolyRing(Q,6);
	RingElem f(P),g(P);
	vector<RingElem> vars=indets(P);
	//f=power(power(vars[1],power(2,10)-1)-1,power(2,10)-1)-power(vars[2],100);//2^64 is too big, 2^32 is OK, degree of long power(2,32)=0
	
	//g=power(power(vars[0],power(2,10)-1),power(2,15)-1);//2^16=0
	//g=power(vars[1]-vars[2],power(2,10));
	/*for (int i=0; i< 65536; i++)
	{
			
		//GlobalOutput() << g << endl;
			g+=i*power(vars[i % 6],i) ;
	}*///pass
	g=power(vars[1],2147483647);
	
//for (int i=0; i< power(2,16); i++)
	//		g+=power(i,2)*power(vars[i % 3] , i % 2^16);
		GlobalOutput() << "f: " << f << endl;
		GlobalOutput() << "g: " << g << endl;
		GlobalOutput() << "max long: " << sizeof(short)*8 << endl;
}

//----------------------------------------------------------------------
// Use main() to handle any uncaught exceptions and warn the user about them.
int main()
{
  try
  {
    program();
    return 0;
  }
  catch (const CoCoA::ErrorInfo& err)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT CoCoA error";
    ANNOUNCE(err);
  }
  catch (const std::exception& exc)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT std::exception: " << exc.what() << endl;
  }
  catch(...)
  {
    GlobalErrput() << "***ERROR***  UNCAUGHT UNKNOWN EXCEPTION" << endl;
  }
  return 1;
}

//----------------------------------------------------------------------
// RCS header/log in the next few lines
// $Header: /Volumes/Home_1/cocoa/cvs-repository/CoCoALib-0.99/examples/ex-empty.C,v 1.4 2008/10/07 12:12:54 abbott Exp $
// $Log: ex-empty.C,v $
// Revision 1.4  2008/10/07 12:12:54  abbott
// Removed useless commented out #include.
//
// Revision 1.3  2007/05/31 16:06:16  bigatti
// -- removed previous unwanted checked-in version
//
// Revision 1.1.1.1  2007/03/09 15:16:11  abbott
// Imported files
//
// Revision 1.9  2007/03/07 11:51:40  bigatti
// -- improved test alignment
//
// Revision 1.8  2007/03/03 14:15:45  bigatti
// -- "foundations" renamed into "GlobalManager"
//
// Revision 1.7  2007/03/02 17:46:40  bigatti
// -- unique RingZ and RingQ
// -- requires foundations.H ;  foundations blah;  (thik of a better name)
//
// Revision 1.6  2007/03/02 10:47:53  cocoa
// First stage of RingZ modifications -- tests do not compile currently, Anna will fix this.
//
// Revision 1.5  2007/03/01 13:52:59  bigatti
// -- minor: fixed typo
//
// Revision 1.4  2007/02/28 15:15:56  bigatti
// -- minor: removed quotes in description
//
// Revision 1.3  2007/02/12 16:27:43  bigatti
// -- added strings ShortDescription and LongDescription for indexing
//
// Revision 1.2  2007/02/10 18:44:03  cocoa
// Added "const" twice to each test and example.
// Eliminated dependency on io.H in several files.
// Improved BuildInfo, and added an example about how to use it.
// Some other minor cleaning.
//
// Revision 1.1.1.1  2006/05/30 11:39:36  cocoa
// Imported files
//
// Revision 1.1  2006/03/12 21:28:34  cocoa
// Major check in after many changes
//
